import request from '../utils/requestbasics';

export function get(url, params) {
  url += '.menu';
  if (params) {
    const paramsArray = [];
    // 拼接参数
    Object.keys(params).forEach(key => paramsArray.push(`${key }=${params[key]}`));
    if (url.search(/\?/) === -1) {
      url += `?${paramsArray.join('&')}`;
    } else {
      url += `&${paramsArray.join('&')}`;
    }
    url += `&token=${sessionStorage.getItem('token')}`;
  } else {
    url += `?token=${sessionStorage.getItem('token')}`;
  }
  return request(url, {
    method: 'get',
  });
}
